package com.test.funcitons.example01;

import java.util.function.BiFunction;
import java.util.function.Function;

public class FunctionComposition {
    public static void main(String[] args) {
        // BiFunction：接受两个参数，返回一个结果
        BiFunction<Integer, Integer, Integer> add = (a, b) -> a + b;

        // Function：接受一个参数，返回一个结果
        Function<Integer, Integer> square = x -> x * x;

        // 组合BiFunction和Function
        BiFunction<Integer, Integer, Integer> addAndSquare = add.andThen(square);

        // 使用组合函数
        int result = addAndSquare.apply(2, 3);

        System.out.println("Result: " + result); // 输出 Result: 25
    }

}
